<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单向链表</title>
</head>

<body>
    <script type="module">
        import { LinkedList } from '../structure/linked_list/linked_list.js'

        const linkedList = new LinkedList()

        linkedList.append('aaa')
        linkedList.append('bbb')
        linkedList.append('ccc')
        linkedList.append('ddd')

        // console.log(linkedList)

        // 插入
        linkedList.insert(1, 'insert at 1')
        linkedList.insert(3, 'insert at 3')

        // console.log(linkedList)

        // 获取
        console.log('get 1:', linkedList.get(1))
        console.log('get 3:', linkedList.get(3))

        // 查找
        console.log('indexOf insert at 1:', linkedList.indexOf('insert at 1'))
        console.log('indexOf insert at 2:', linkedList.indexOf('insert at 2'))

        // 移除
        console.log('removeAt 3:', linkedList.removeAt(3))
        console.log(linkedList)

        // 可视化
        console.log('当前链表：', linkedList.toString())

        // 更新
        console.log('更新位置1的旧节点:', linkedList.update(1, 'update At 1'))
        console.log('更新完的当前链表:', linkedList.toString())

        // 删除
        linkedList.remove('update At 1')
        console.log('删除后的当前链表:', linkedList.toString())

        // 是否为空
        console.log('是否为空:', linkedList.isEmpty())
        console.log('size:', linkedList.size())
    </script>
</body>

</html>